Skip to content

fix: repair failing tests and type errors across api and shared packages - #105

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-4801-1785032024
Open

fix: repair failing tests and type errors across api and shared packages#105
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-4801-1785032024

Conversation

@stooit

@stooit stooit commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and eliminates all type errors. bun test && bunx tsc --noEmit now passes: 22 tests pass, 0 failures, 0 type errors.

Bugs spanned both the api and shared packages.

Changes

File Fix
packages/shared/src/types.ts Renamed userNameusername to match the field name used by API routes and tests.
packages/shared/src/utils/pagination.ts Implemented paginate() — was a stub that threw not implemented. Slices by page/size, computes total and totalPages via Math.ceil, handles empty arrays and out-of-range pages.
packages/api/src/middleware/auth.ts Fixed case-sensitivity bug: public-methods list had lowercase 'post' but Hono's c.req.method is uppercase 'POST', so POST /users incorrectly required a token.
packages/api/src/routes/users.ts Added missing badRequest import and switched to the canonical username field.
tsconfig.json Added "types": ["bun-types"] to resolve the process.env typing error. bun-types was already installed; strict remains on.

Verification

  • bun test → 22 pass / 0 fail
  • bunx tsc --noEmit → clean (exit 0)

Constraints honoured

  • No test files modified.
  • No new dependencies added (bun-types pre-existing; package.json/lockfile unchanged).
  • tsconfig change does not weaken type safety.
  • Independently reviewed: verdict APPROVE.

Assumptions

  • Canonical user field name is username (chosen because tests and route handlers use it; only the shared type diverged).

- shared/types: rename userName -> username to match API routes and tests
- shared/pagination: implement paginate() (was a throwing stub)
- api/auth middleware: fix case-sensitivity bug (public method 'post' -> 'POST')
- api/users route: import badRequest, use canonical username field
- tsconfig: add bun-types to types array to resolve process.env typing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant